/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.ems.service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.DateUtils;
import com.thinkgem.jeesite.modules.ems.entity.EmsStudent;
import com.thinkgem.jeesite.modules.ems.dao.EmsStudentDao;

/**
 * 学员Service
 * @author zad
 * @version 2018-01-25
 */
@Service
@Transactional(readOnly = true)
public class EmsStudentService extends CrudService<EmsStudentDao, EmsStudent> {

	public EmsStudent get(String id) {
		return super.get(id);
	}
	
	public List<EmsStudent> findList(EmsStudent emsStudent) {
		return super.findList(emsStudent);
	}
	
	public Page<EmsStudent> findPage(Page<EmsStudent> page, EmsStudent emsStudent) {
		return super.findPage(page, emsStudent);
	}
	
	@Transactional(readOnly = false)
	public void save(EmsStudent emsStudent) {
		super.save(emsStudent);
	}
	
	@Transactional(readOnly = false)
	public void delete(EmsStudent emsStudent) {
		super.delete(emsStudent);
	}
	
	public String qryStudentSeq(Map<String,String> param)
	{
		return dao.qryStudentSeq(param);
	}
	
	public List<EmsStudent> checkExists(EmsStudent emsStudent)
	{
		return dao.checkExists(emsStudent);
	}
	
	// 创建下月学号生成序列
	public void createStuNoSeq(Map<String,String> param)
	{
		dao.createStuNoSeq(param);
	}
	
	// 删除上月月学号生成序列
	public void dropStuNoSeq(Map<String,String> param)
	{
		dao.dropStuNoSeq(param);
	}
	
	public String generateStuNo()
	{
		String date = DateUtils.getDate("yyyyMM");
		
		String month = DateUtils.getAnyMonth(new Date(), 0);
		Map<String,String> param = new HashMap<String,String>();
		param.put("month", month);
		
		String noSeq = this.qryStudentSeq(param);
		return date + noSeq;
	}
}